package cn.cvs.servlet;

import cn.cvs.pojo.Card;
import cn.cvs.service.CardService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

@WebServlet("/DelServlet")
public class DelServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("UTF-8");
        response.setContentType("text/html;charset=UTF-8");
        CardService cardService = new CardService();
        int id =Integer.parseInt(request.getParameter("id"));
        int count =cardService.del(id);
        if (count>0){
            request.setAttribute("info","删除成功！");
        }else {
            return;
        }
        request.getRequestDispatcher("ListServlet").forward(request,response);
    }
}
